package com.denlaku.longan.service.impl;

import com.denlaku.longan.anno.RequiredTx;
import com.denlaku.longan.repository.LookupRepository;
import com.denlaku.longan.service.LookupService;
import com.denlaku.longan.util.SnowflakeUtils;
import com.denlaku.longan.vo.Lookup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author tianx
 */
@Service
public class LookupServiceImpl implements LookupService {
    @Autowired
    private LookupRepository lookupRepository;

    /**
     * 查询lookup
     * @param query 查询参数
     * @return lookup列表
     */
    @Override
    public List<Lookup> list(Lookup query) {
        return lookupRepository.list(query);
    }

    /**
     * 获取lookup
     * @param query 查询参数
     * @return Lookup
     */
    @Override
    public Lookup get(Lookup query) {
        return lookupRepository.get(query);
    }

    /**
     * 新增lookup
     * @param lookup lookup
     * @return 新增行数
     */
    @Override
    @RequiredTx
    public Integer add(Lookup lookup) {
        lookup.setId(SnowflakeUtils.nextId());
        return lookupRepository.add(lookup);
    }

    /**
     * 更新lookup
     * @param lookup lookup
     * @return 更新行数
     */
    @Override
    @RequiredTx
    public Integer update(Lookup lookup) {
        return lookupRepository.update(lookup);
    }

    /**
     * 删除lookup
     * @param lookup 参数
     * @return 删除行数
     */
    @Override
    @RequiredTx
    public Integer delete(Lookup lookup) {
        return lookupRepository.delete(lookup);
    }
}
